package com.yinda.dt.produce.app;

import android.content.Context;

import com.xcgame.oh.OkHttp;
import com.xcgame.oh.ResponseCallback;
import com.xcgame.oh.UploadResponseCallback;
import com.yinda.dt.produce.utils.DesUtil;

import org.json.JSONObject;

import java.io.File;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

/**
 * Created by Administrator on 2017/3/30.
 */

public class MyOkHttp extends OkHttp {

    public MyOkHttp() {
        super(15, 30, 30);
    }

    public Call post(Context context, String url, JSONObject jsonParams, ResponseCallback callback) {

        Map<String, String> map = new HashMap<>();
        try {
            map.put("request", URLEncoder.encode(new DesUtil("dtsbsbdsb", true).encode(URLEncoder.encode(jsonParams.toString(), "utf-8")), "utf-8"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return super.post(context, url, map, callback);
    }

    public Call uploadFile(Context context, String url, JSONObject jsonParams, File file, UploadResponseCallback callback) {
        Map<String, String> map = new HashMap<>();
        try {
            map.put("request", URLEncoder.encode(new DesUtil("dtsbsbdsb", true).encode(URLEncoder.encode(jsonParams.toString(), "utf-8")), "utf-8"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return super.uploadFile(context, url, map, file, callback);
    }
}
